package com.wlts.wzy.configBean.DyConfig;
import com.wlts.wzy.DYUserModule.entity.DyOauth;
import com.wlts.wzy.DYUserModule.entity.DyStoreUser;
import com.wlts.wzy.DYUserModule.service.IDyOauthService;
import com.wlts.wzy.expand.MyLambdaQueryWrapper;
import com.wlts.wzy.util.LoginUserUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DyConfig {

    @Autowired
    private IDyOauthService ksOauthService;


    public DyStoreUser getDyStoreUserConfig() {

        Subject subject = SecurityUtils.getSubject();

        DyStoreUser storeUser = LoginUserUtil.getLoginDyStoreUser(subject);

        MyLambdaQueryWrapper<DyOauth> queryWrapper = new MyLambdaQueryWrapper<>();

        queryWrapper.eq(DyOauth::getUserUuid, storeUser.getUuid());

        storeUser.setDyOauth(ksOauthService.getOne(queryWrapper));

        return storeUser;

    }


    public DyOauth getDyConfig(String userUuid) {


        MyLambdaQueryWrapper<DyOauth> queryWrapper = new MyLambdaQueryWrapper<>();

        queryWrapper.eq(DyOauth::getUserUuid, userUuid);

        return ksOauthService.getOne(queryWrapper);

    }

}
